import axios from 'axios'

const request = axios.create({
  baseURL: 'http://120.26.209.113:8080/',
  timeout: 8000, // 超时时间
  // withCredentials: true, // 是否允许带cookie这些
  headers: {
    'X-Requested-With': 'XMLHttpRequest',
    'Content-Type': 'application/json;charset=utf-8'
  }
})
// Add a request interceptor 请求拦截器
request.interceptors.request.use(
  function (config) {
    // this.$loading({})
    return config
  },
  function (error) {
    // Do something with request error
    return Promise.reject(error)
  }
)

// Add a response interceptor 响应拦截器
request.interceptors.response.use(
  function (response) {
    // Do something with response data
    return response
  },
  function (error) {
    // Do something with response error
    return Promise.reject(error)
  }
)

export default request
